using UnityEngine;
using JufGame.Collections.Generic;
using System;

namespace JufGame
{
	public class SolutionTrans : IComparable<SolutionTrans>
    {
		public LOD_Character User;
		public Vector3 RelAudacity; //相对真实度变化
		public Vector4 RelCost; //相对耗费变化
		public float BestRatio; //用于优先队列排序
		public FeatureSolution toSolution; //转化到的特征解决方案
		private FeatureSolution lastSolution; //上次转化到的特征解决方案
		public SolutionTrans(FeatureSolution toSolution, Vector3 relAudacity, Vector4 relCost)
		{
			this.toSolution= toSolution;
			RelAudacity = relAudacity;
			RelCost = relCost;
		}
		public SolutionTrans(LOD_Character user, SolutionTrans trans)
		{
			User = user;
			if (trans != null)
			{
				toSolution = trans.toSolution;
				RelCost = trans.RelCost;
				BestRatio = trans.BestRatio;
			}
		}
		public void SetTransInfo(SolutionTrans trans)
		{
			if (trans != null)
			{
				toSolution = trans.toSolution;
				RelCost = trans.RelCost;
				BestRatio = trans.BestRatio;
			}
		}
        public int CompareTo(SolutionTrans other)
        {
			return BestRatio.CompareTo(other.BestRatio);
		}
		
		/// <summary>
		/// 执行交易
		/// </summary>
		public void RunTrade()
		{
			lastSolution = User.Feature_Solution;
			User.Real_RunTrade(toSolution);
		}

		/// <summary>
		/// 执行上一次执行过的交易
		/// </summary>
		public void RecoverTrade()
		{
			User.Real_RunTrade(lastSolution);
		}
    }
}
